//
//  OnlineExamViewController.m
//  jinnengExam
//
//  Created by mac on 2020/11/13.
//  Copyright © 2020 jznrj. All rights reserved.
//

#import "OnlineExamViewController.h"
#import <NinaPagerView.h>
#import <UIParameter.h>
#import "WaitingExamViewController.h"
#import "OnlineExamedViewController.h"

@interface OnlineExamViewController ()
@property(nonatomic, strong) NinaPagerView *pageView;
@property(nonatomic, strong) NSMutableArray *titleArray;
@property(nonatomic, strong) NSMutableArray *vcsArray;
@end

@implementation OnlineExamViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"在线考试";
    UINavigationBar * bar = self.navigationController.navigationBar;
        UIImage *bgImage = [ColorUtil navigationBarColor:[ColorUtil titleColor] BarSize:bar.frame alphe:1.0];
        [bar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
        [bar setTintColor:[UIColor whiteColor]];
        [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]}forState:UIControlStateNormal];
        [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
    // Do any additional setup after loading the view.
    self.tabBarController.tabBar.frame = CGRectMake(0, 0, 0, 0);
    self.tabBarController.tabBar.hidden = YES;
    [self initView];
}
-(void) viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(void) initView{
    _titleArray = [[NSMutableArray alloc]init];
    [_titleArray addObject:@"待考"];
    [_titleArray addObject:@"已考"];
    _vcsArray =[[NSMutableArray alloc]init];
    WaitingExamViewController *vc1 = [[WaitingExamViewController alloc]init];
    OnlineExamedViewController *vc2 = [[OnlineExamedViewController alloc]init];
    
    [_vcsArray addObject:vc1];
    [_vcsArray addObject:vc2];
    
    [self.view addSubview:self.pageView];
    
}

- (NinaPagerView *)pageView {
    if (!_pageView) {
        /**
         *  创建ninaPagerView，控制器第一次是根据您划的位置进行相应的添加的，类似网易新闻虎扑看球等的效果，后面再滑动到相应位置时不再重新添加，如果想刷新数据，您可以在相应的控制器里加入刷新功能。需要注意的是，在创建您的控制器时，设置的frame为FUll_CONTENT_HEIGHT，即全屏高减去导航栏高度，如果这个高度不是您想要的，您可以去在下面的frame自定义设置。
         *  A tip you should know is that when init the VCs frames,the default frame i set is FUll_CONTENT_HEIGHT,it means fullscreen height - NavigationHeight - TabbarHeight.If the frame is not what you want,just set frame as you wish.
         */
        CGRect pagerRect = CGRectMake(0, 0, FUll_VIEW_WIDTH, self.view.frame.size.height);
        _pageView = [[NinaPagerView alloc] initWithFrame:pagerRect WithTitles:self.titleArray WithObjects:self.vcsArray];
        _pageView.ninaPagerStyles = NinaPagerStyleBottomLine;
        _pageView.titleFont = 10*LSCALE;
        _pageView.topTabHeight = 20*LSCALE;
    }
    return _pageView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
